//
//  BarCodeViewController.m
//  Weibo
//
//  Created by wpapple on 16/6/1.
//  Copyright © 2016年 红红火火恍恍惚惚嘿嘿嘿. All rights reserved.
//

#import "BarCodeViewController.h"

@interface BarCodeViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *barCodeScanLine;
@property (strong , nonatomic) CADisplayLink * link;
@property (weak, nonatomic) IBOutlet UIImageView *barCode;

@end

@implementation BarCodeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.link = [CADisplayLink displayLinkWithTarget:self selector:@selector(barCodeScanlineWillMove)];
    [self.link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)barCodeScanlineWillMove{
    
    self.barCodeScanLine.transform = CGAffineTransformTranslate(self.barCodeScanLine.transform, 3, 0);
    if (self.barCodeScanLine.transform.tx > self.barCode.width) {
        self.barCodeScanLine.transform = CGAffineTransformIdentity;
    }
}

- (IBAction)closeThisController:(UIBarButtonItem *)sender {
    
    [self.link invalidate];
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}

- (IBAction)touchAblumButton:(UIBarButtonItem *)sender {
    
    UIImagePickerController * imagePickerController = [[UIImagePickerController alloc]init];
    [self showViewController:imagePickerController sender:nil];
    
}

@end
